const path = require('path');
const cors = require('koa2-cors');
// const wechat = require('think-wechat');
const isDev = think.env === 'development';

module.exports = [
  {
    handle: cors,
    options: {
      credentials: true
    }
  },
  {
    handle: 'meta',
    options: {
      logRequest: isDev,
      sendResponseTime: isDev
    }
  }, {
    handle: 'resource',
    enable: isDev,
    options: {
      root: path.join(think.ROOT_PATH, 'www'),
      publicPath: /^\/(static|favicon\.ico)/
    }
  }, {
    handle: 'trace',
    enable: !think.isCli,
    options: {
      debug: isDev
    }
  }, {
    handle: 'payload',
    options: {
      keepExtensions: true,
      limit: '5mb',
      uploadDir: path.join(think.ROOT_PATH, ''),
      multiples: true
    }
  },

  {
    handle: 'apinfo',
    options: {}
  }, {
    handle: 'tokencheck',
    options: {}
  },
  // }, {
  //   handle: 'authority',
  //   options: {}
  // },
  // {
  //   handle: swaggerParser,
  //   options: {
  //     debug: isDev,
  //     api_doc: './api/swagger.yaml',
  //     controller_dir: './app/controller'
  //   }
  // },
  {
    handle: 'router',
    options: {}
  },
  // {
  //   handle: swaggerRouter,
  //   options: {
  //     debug: isDev
  //   }
  // },
  {
    handle: 'logic',
    options: {}
  },
  {
    handle: 'controller',
    options: {}
  }
  // {
  //   handle: swaggerController,
  //   options: {
  //     debug: isDev
  //   }
  // }
];
